/*    */ package com.zimbra.cs.util;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.account.Key.DistributionListBy;
/*    */ import com.zimbra.common.lmtp.SmtpToLmtp.RecipientValidator;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.util.Log;
/*    */ import com.zimbra.common.util.LogFactory;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.DynamicGroup;
/*    */ import com.zimbra.cs.account.Group;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import java.util.Arrays;
/*    */ import java.util.Collections;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class SmtpRecipientValidator
/*    */   implements SmtpToLmtp.RecipientValidator
/*    */ {
/* 41 */   private static final Log log = LogFactory.getLog(SmtpRecipientValidator.class);
/*    */   
/*    */   public Iterable<String> validate(String recipient)
/*    */   {
/*    */     try {
/* 46 */       Provisioning prov = Provisioning.getInstance();
/* 47 */       Account account = prov.get(Key.AccountBy.name, recipient);
/* 48 */       if (account != null) {
/* 49 */         return Arrays.asList(new String[] { account.getName() });
/*    */       }
/* 51 */       Group group = prov.getGroup(Key.DistributionListBy.name, recipient);
/* 52 */       if (group != null) { String[] members;
/*    */         String[] members;
/* 54 */         if ((group instanceof DynamicGroup)) {
/* 55 */           members = ((DynamicGroup)group).getAllMembers(true);
/*    */         } else {
/* 57 */           members = group.getAllMembers();
/*    */         }
/* 59 */         return Arrays.asList(members);
/*    */       }
/*    */     }
/*    */     catch (ServiceException e) {
/* 63 */       log.error("Unable to validate recipient %s", recipient, e);
/*    */     }
/* 65 */     return Collections.emptyList();
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/util/SmtpRecipientValidator.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */